import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'
import { OrganizationIdentityLevel, ProjectRegionTree } from '../Common/Conversion'

export const ProjectCompanyInfos = async ({ url, OptionsEvent, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}OC`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '8019a401-abe9-4447-9acd-ceec95d67ca3') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增项目公司" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'organizationUuid',
                title: '组织机构',
                valueType: 'select',
                valueEnum: await OrganizationIdentityLevel(3),
                ellipsis: true,
                width: 300,
                rules: true,
            },
            {
                dataIndex: 'responsiblePerson',
                title: '负责人',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'roadProjectCount',
                title: '交通项目个数',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'municipalProjectCount',
                title: '市政项目个数',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'houseProjectCount',
                title: '房建项目个数',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'developmentProjectCount',
                title: '开发区项目个数',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'heatingProjectCount',
                title: '供热管网改造个数',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'meterageMobile',
                title: '计量电话',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'projectRegionUuid',
                title: '合作区县',
                valueType: 'treeSelect',
                ellipsis: true,
                hideInSearch: true,
                fieldProps: {
                    options: await ProjectRegionTree(),
                    fieldNames: { label: 'tableName', value: 'uuid' },
                },
                width: 150,
            },
            {
                dataIndex: 'buildDuration',
                title: '建设期限',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'projectName',
                title: '项目名称',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 250,
            },
            {
                dataIndex: 'startDate',
                title: '开始日期',
                valueType: 'Date',
                ellipsis: true,
                hideInSearch: true,
                showTime: true,
                width: 150,
            },
            {
                dataIndex: 'currentPeriod',
                title: '项目阶段',
                valueType: 'select',
                ellipsis: true,
                hideInSearch: true,
                valueEnum: BuiltInData.CurrentPeriod,
                width: 150,
            },
            {
                dataIndex: 'totalInvestment',
                title: '总投资(万元)',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'capitalAmount',
                title: '资本金总额(万元)',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'capitalPercent',
                title: '资本金占比(%)',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'socialProjectCapitalRatio',
                title: '社会资本方资本金与项目资本金占比(%)',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 280,
            },
            {
                dataIndex: 'badaShouldCapitalAmount',
                title: '八达路桥公司资本金情况(应投 万元)',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 240,
            },
            {
                dataIndex: 'badaCompletedCapitalAmount',
                title: '八达路桥公司资本金情况(已投 万元)',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 240,
            },
            {
                dataIndex: 'earningRatio',
                title: '财务内部收益率(%)',
                valueType: 'inputNumber',
                ellipsis: true,
                hideInSearch: true,
                width: 240,
            },
            {
                dataIndex: 'cooperationDuration',
                title: '合作期限（建+养）',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'projectCompanyCoordinate',
                title: '坐标',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            { ...commonTableList.code, rules: true },
            { ...commonTableList.sortId, rules: true },
            { ...commonTableList.isEnabled, rules: true },
            {
                dataIndex: 'projectOverview',
                title: '项目概况',
                valueType: 'textarea',
                ellipsis: true,
                hideInSearch: true,
                width: 400,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '7b5b03c7-f35c-4e7b-9fd7-25171f7465b0') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        <OpenTwoRouter
                            key="TwoOne"
                            title="菜单配置"
                            twoTitle="公司菜单配置"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'ProjectSetUp',
                                Permission,
                                actionRef,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        Permission.findIndex(v => v.uuid === '9e2cf5c9-b197-4947-a4ba-e1e3067bb460') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
